package com.onpositive.gamemaker.editor;

import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.internal.WorkbenchPage;

@SuppressWarnings("restriction")
public class ViewUtil
{
	public static IViewReference getReference(String viewId) {
		IWorkbenchPage activePage = EditorUtil.getActivePage();		
		IViewReference viewRef = ((WorkbenchPage) activePage).getActivePerspective().findView(viewId);		
		return viewRef;
	}
	
	public static IViewPart showView(String viewId)
	{
		IWorkbenchPage activePage = EditorUtil.getActivePage();
		try
		{
			return activePage.showView(viewId);
		} catch (PartInitException e)
		{
			GameCreatorEditorPlugin.logError(e);
		}
		return null;
	}
}
